Skip to content

Conversation

@marcprux
Copy link
Contributor

The Android CI added in #172 will build against the Swift SDK for Android using the scripts/install-and-build-with-sdk.sh support for building with cross-compilation SDKs, but it does't actually test the package. This PR adds a scripts/android/android-emulator-tests.sh script that will install and configure an Android emulator and then transfer the test cases over to it and run the tests on the emulator.

Notes:

  • In addition to the build-only enable_android_sdk_build input to workflows/swift_package_test.yml, we now have an enable_android_sdk_checks boolean which will additionally run a package's test cases.
  • The Android emulator requires KVM to be enabled for acceleration, which is not possible in a nested docker container. I saw no reason why the SDK build needs to take place in a nested container, so I moved it to run on the top-level ubuntu-latest container.
  • The emulator will only run on x86_64; since we support building against multiple triples (currently defaulting to aarch64-unknown-linux-android28 and x86_64-unknown-linux-android28 in workflows/swift_package_test.yml), we will still build against each of these archs, but only test against x86_64.
  • As mentioned previously (Add Android emulator testing to workflow #179 (comment)), not all package testing will pass out of the box, since some tests rely on hardcoded #filePath references to test data (e.g., in swift-crypto), which will not work when the tests are run in an emulator with a separate filesystem. I expect that some of these packages will need to be updated if we are to enable enable_android_sdk_checks for them.

A successful run can be seen at https://github.com/swift-android-sdk/github-workflows/actions/runs/20244304679/job/58120240667

Closes #179 and #83

CC: @finagolfin, @justice-adams-apple, @etcwilde, @shahmishal

@marcprux marcprux requested a review from a team as a code owner December 15, 2025 20:05
@marcprux marcprux requested a review from finagolfin December 17, 2025 02:56
@marcprux
Copy link
Contributor Author

Could we get some more eyes on this, perhaps by @jakepetroules and/or @justice-adams-apple? I'd like to start testing out various swiftlang projects with Android testing enabled, which will be important for ensuring the quality and stability of the 6.3 release.

android-sdk-build:
name: Swift SDK for Android Build (${{ matrix.swift_version }} - ${{ matrix.os_version }} - NDK ${{ matrix.ndk_version }})
name: Swift SDK for Android Build (${{ matrix.swift_version }} - NDK ${{ matrix.ndk_version }})
runs-on: ubuntu-latest
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we lose some level of coverage here by removing all the SDK builds from docker? Previously we were testing the static SDK builds on a number of different OS's using docker (whatever the repo owner specified with linux_os_versions, is there any concern with the loss of coverage for the Swift SDK for Android ?

Admittedly I'm not Sure how much value that created, maybe that coverage was minimal?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like it was overkill, since we are cross-compiling to a different target. It is theoretically possible that some host toolchain issue might get caught by this, but I figured that all the other host toolchains matrix variants that are running in Docker (including the cross-compilation provided by the static SDK) would catch these build issues.

Besides, we can't run the Android emulator tests in Docker due to nested virtualization, so we'd only be able to see if the package builds, not if it passes the tests.

…at the last triple in the list is used for emulator testing
Copy link
Contributor

@justice-adams-apple justice-adams-apple left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we'll definitely want to squash this I assume 👍

@marcprux
Copy link
Contributor Author

marcprux commented Jan 6, 2026

we'll definitely want to squash this I assume 👍

For sure!

If you can Squash & Merge, please go ahead. Otherwise, I can rebase and squash in the branch.

Copy link
Member

@shahmishal shahmishal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @marcprux and everyone who provided feedback!

@shahmishal shahmishal merged commit 4905c1c into swiftlang:main Jan 6, 2026
107 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Android emulator testing to workflow

4 participants